package com.technology.education.ui.teacher.order

import androidx.lifecycle.MutableLiveData
import com.technology.education.data.model.TeacherOrderListModel
import com.technology.education.ext.showLog
import com.technology.education.network.apiService
import me.hgj.jetpackmvvm.base.viewmodel.BaseViewModel
import me.hgj.jetpackmvvm.ext.request
import me.hgj.jetpackmvvm.state.ResultState

class OrderListViewModel : BaseViewModel() {
    var type: Int = 0
    val result = MutableLiveData<ResultState<TeacherOrderListModel>>()
    val delResult=MutableLiveData<String>()
    override fun getData() {
        super.getData()
        request({
            apiService.teachOrderListTeacher(
                hashMapOf(
                    "pageNo" to pageIndex,
                    "pageSize" to pageSize,
                    "state" to if (type == 0) "" else type
                )
            )
        }, result)
    }

    fun deleteOrder(id:String){
        request({ apiService.delTeachOrderTeacher(id)},success = {
            delResult.postValue(id)
        })
    }
}